
CPP = g++
CPPFLAGS = -g 
TARGET = chat_server

all: $(TARGET)


MUDUO_DIR=../deps/build/release-cpp11/lib
INCLUDE_DIRS = -I redis -I ../deps/libevent/include -I ../deps/libevent/build/include \
	-I ../deps/muduo -I . -I ../public
SRC_DIRS = . redis
LIBS = -L ../deps/libevent/build/lib -levent ../deps/hiredis/libhiredis.a \
	$(MUDUO_DIR)/libmuduo_net.a $(MUDUO_DIR)/libmuduo_base.a -lpthread -lmysqlclient -lconfig++
SRCS = $(shell find $(SRC_DIR) -name "*.cpp")

OBJS=$(SRCS:%.cpp=obj/%.o) 


$(OBJS):obj/%.o : %.cpp
	$(shell mkdir -p $(dir $@))
	$(CPP) $(CPPFLAGS) -o $@ -c $< $(INCLUDE_DIRS)

$(TARGET):$(OBJS)
	$(CPP) -o $@ $(OBJS) $(LIBS)

#$(warning $(SRCS))
#$(warning $(OBJS))
#$(warning $(dir $(SRCS)))

.PHONY: clean
clean:
	rm -rf $(TARGET) $(OBJS)